#include "../include/tcpServer.h"

TcpServer::TcpServer(const string & ip,unsigned short port)
:_acceptor(ip,port)
,_loop(_acceptor)
{


}

TcpServer::~TcpServer()
{

}

void TcpServer::start()
{
	_acceptor.ready();
	_loop.loop();
}

void TcpServer::stop()
{
	_loop.unloop();
}

void TcpServer::setAllCallBack(function<void(const shared_ptr<TcpConnection> & con)> && callBack1,
					           function<void(const shared_ptr<TcpConnection> & con)> && callBack2,
								function<void(const shared_ptr<TcpConnection> & con)> && callBack3
						)
{
	_loop.setNewConnectionCallBack(std::move(callBack1));
	_loop.setMessageCallBack(std::move(callBack2));
	_loop.setCloseCallBack(std::move(callBack3));
}

